<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .container {
      display: grid;
      grid-template-columns: repeat(4, 100px);
      grid-template-rows: repeat(2, 100px);
      height: 400px;
      background-color: red;
      /* justify-content: center; */
      /* justify-content: space-around; */
      /* justify-content: space-between; */
      /* justify-content: space-evenly; */
      /* align-content: center; */
      /* align-content: end; */
      /* align-content: space-around; */
      /* align-content: space-between; */
      /* align-content: space-evenly; */

      /* place-content: center center; */
    }
    .item {
      border: 1px solid #333;
      /* 当只有一行可以直接设置高度 */
      /* height: 200px; */
      background-color: #fff;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
    <div class="item">4</div>
    <div class="item">5</div>
    <div class="item">6</div>
    <div class="item">7</div>
    <div class="item">8</div>
  </div>
</body>
</html>